This snippet was orginally taken from Help understand Click to View Object Script
using UnityEngine;
using System.Collections;
public class ChangeLookAtTarget : MonoBehaviour {
public GameObject target; // the target that the camera should look at
void Start() {
if (target == null)
{
target = this.gameObject;
Debug.Log ("ChangeLookAtTarget target not specified. Defaulting to parent GameObject");
}
}
// Called when MouseDown on this gameObject
void OnMouseDown () {
// change the target of the LookAtTarget script to be this gameobject.
LookAtTarget.target = target;
Camera.main.fieldOfView = 60*target.transform.localScale.x;
}
}
Hiya. I'm Ronald, an Industrial Engineer from Colombia. Hope you enjoyed my ad-free, bullshit-free site. If you liked it, tell someone about it.